﻿using System;

namespace UniRx.Operators
{
	// Token: 0x02000376 RID: 886
	internal class ZipLatestObservable<T1, T2, T3, T4, T5, T6, T7, TR> : OperatorObservableBase<TR>
	{
		// Token: 0x0600120E RID: 4622 RVA: 0x00052A78 File Offset: 0x00050E78
		public ZipLatestObservable(IObservable<T1> source1, IObservable<T2> source2, IObservable<T3> source3, IObservable<T4> source4, IObservable<T5> source5, IObservable<T6> source6, IObservable<T7> source7, ZipLatestFunc<T1, T2, T3, T4, T5, T6, T7, TR> resultSelector) : base(source1.IsRequiredSubscribeOnCurrentThread<T1>() || source2.IsRequiredSubscribeOnCurrentThread<T2>() || source3.IsRequiredSubscribeOnCurrentThread<T3>() || source4.IsRequiredSubscribeOnCurrentThread<T4>() || source5.IsRequiredSubscribeOnCurrentThread<T5>() || source6.IsRequiredSubscribeOnCurrentThread<T6>() || source7.IsRequiredSubscribeOnCurrentThread<T7>())
		{
			this.source1 = source1;
			this.source2 = source2;
			this.source3 = source3;
			this.source4 = source4;
			this.source5 = source5;
			this.source6 = source6;
			this.source7 = source7;
			this.resultSelector = resultSelector;
		}

		// Token: 0x0600120F RID: 4623 RVA: 0x00052B1D File Offset: 0x00050F1D
		protected override IDisposable SubscribeCore(IObserver<TR> observer, IDisposable cancel)
		{
			return new ZipLatestObservable<T1, T2, T3, T4, T5, T6, T7, TR>.ZipLatest(7, this, observer, cancel).Run();
		}

		// Token: 0x04000ADD RID: 2781
		private IObservable<T1> source1;

		// Token: 0x04000ADE RID: 2782
		private IObservable<T2> source2;

		// Token: 0x04000ADF RID: 2783
		private IObservable<T3> source3;

		// Token: 0x04000AE0 RID: 2784
		private IObservable<T4> source4;

		// Token: 0x04000AE1 RID: 2785
		private IObservable<T5> source5;

		// Token: 0x04000AE2 RID: 2786
		private IObservable<T6> source6;

		// Token: 0x04000AE3 RID: 2787
		private IObservable<T7> source7;

		// Token: 0x04000AE4 RID: 2788
		private ZipLatestFunc<T1, T2, T3, T4, T5, T6, T7, TR> resultSelector;

		// Token: 0x02000377 RID: 887
		private class ZipLatest : NthZipLatestObserverBase<TR>
		{
			// Token: 0x06001210 RID: 4624 RVA: 0x00052B2D File Offset: 0x00050F2D
			public ZipLatest(int length, ZipLatestObservable<T1, T2, T3, T4, T5, T6, T7, TR> parent, IObserver<TR> observer, IDisposable cancel) : base(length, observer, cancel)
			{
				this.parent = parent;
			}

			// Token: 0x06001211 RID: 4625 RVA: 0x00052B4C File Offset: 0x00050F4C
			public IDisposable Run()
			{
				//this.c1 = new ZipLatestObserver<!0>(this.gate, this, 0);
				//this.c2 = new ZipLatestObserver<!1>(this.gate, this, 1);
				//this.c3 = new ZipLatestObserver<!2>(this.gate, this, 2);
				//this.c4 = new ZipLatestObserver<!3>(this.gate, this, 3);
				//this.c5 = new ZipLatestObserver<T5>(this.gate, this, 4);
				//this.c6 = new ZipLatestObserver<T6>(this.gate, this, 5);
				//this.c7 = new ZipLatestObserver<T7>(this.gate, this, 6);
				//IDisposable disposable = this.parent.source1.Subscribe(this.c1);
				//IDisposable disposable2 = this.parent.source2.Subscribe(this.c2);
				//IDisposable disposable3 = this.parent.source3.Subscribe(this.c3);
				//IDisposable disposable4 = this.parent.source4.Subscribe(this.c4);
				//IDisposable disposable5 = this.parent.source5.Subscribe(this.c5);
				//IDisposable disposable6 = this.parent.source6.Subscribe(this.c6);
				//IDisposable disposable7 = this.parent.source7.Subscribe(this.c7);
				return StableCompositeDisposable.Create(new IDisposable[]
				{
					//disposable,
					//disposable2,
					//disposable3,
					//disposable4,
					//disposable5,
					//disposable6,
					//disposable7
				});
			}

			// Token: 0x06001212 RID: 4626 RVA: 0x00052CAC File Offset: 0x000510AC
			public override TR GetResult()
			{
				return this.parent.resultSelector(this.c1.Value, this.c2.Value, this.c3.Value, this.c4.Value, this.c5.Value, this.c6.Value, this.c7.Value);
			}

			// Token: 0x06001213 RID: 4627 RVA: 0x00052D16 File Offset: 0x00051116
			public override void OnNext(TR value)
			{
				this.observer.OnNext(value);
			}

			// Token: 0x06001214 RID: 4628 RVA: 0x00052D28 File Offset: 0x00051128
			public override void OnError(Exception error)
			{
				try
				{
					this.observer.OnError(error);
				}
				finally
				{
					base.Dispose();
				}
			}

			// Token: 0x06001215 RID: 4629 RVA: 0x00052D60 File Offset: 0x00051160
			public override void OnCompleted()
			{
				try
				{
					this.observer.OnCompleted();
				}
				finally
				{
					base.Dispose();
				}
			}

			// Token: 0x04000AE5 RID: 2789
			private readonly ZipLatestObservable<T1, T2, T3, T4, T5, T6, T7, TR> parent;

			// Token: 0x04000AE6 RID: 2790
			private readonly object gate = new object();

			// Token: 0x04000AE7 RID: 2791
			private ZipLatestObserver<T1> c1;

			// Token: 0x04000AE8 RID: 2792
			private ZipLatestObserver<T2> c2;

			// Token: 0x04000AE9 RID: 2793
			private ZipLatestObserver<T3> c3;

			// Token: 0x04000AEA RID: 2794
			private ZipLatestObserver<T4> c4;

			// Token: 0x04000AEB RID: 2795
			private ZipLatestObserver<T5> c5;

			// Token: 0x04000AEC RID: 2796
			private ZipLatestObserver<T6> c6;

			// Token: 0x04000AED RID: 2797
			private ZipLatestObserver<T7> c7;
		}
	}
}
